lib/repo: Add timestamps to OstreeRepoFinderResult
authorMatthew Leeds <matthew.leeds@endlessm.com>
Wed, 28 Mar 2018 07:31:05 +0000 (00:31 -0700)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 3 Apr 2018 15:50:40 +0000 (15:50 +0000)
commitcb3360fca656a478ba407c879f3cc675da78fe87
tree4066c90156f0718403ac5535b3903f50d298a460
parentc4c2b5ebd155f9d17531db4ab9c2516699132745
lib/repo: Add timestamps to OstreeRepoFinderResult

Currently OstreeRepoFinderResult, a data structure used by pull code
that supports P2P operations, has a hash table mapping refs to checksums
but doesn't include timestamp information. This means that clients have
no way of knowing just from the OstreeRepoFinderResult information if a
commit being offered by a peer remote is an update or downgrade until
they start pulling it. The client could check the summary or the commit
metadata for the timestamps, but this requires adding the temporary
remotes to the repo config, and ostree is already checking timestamps
before returning the results, so I think it makes more sense for them to
be returned rather than leaving it to the client. This limitation is
especially important for offline computers, because for online computers
the latest commit available from any remote is the latest commit,
period.

This commit adds a "ref_to_timestamp" hash table to
OstreeRepoFinderResult that is symmetric to "ref_to_checksum" in that it
shares the same keys. This is an API break, but it's part of the
experimental API, and none of the current users of that (flatpak,
eos-updater, and gnome-software) are affected. See the documentation for
more details on "ref_to_timestamp". One thing to note is the data
structure currently gets initialized in find_remotes_cb(), so only users
of ostree_repo_find_remotes_async() will get them, not users of, say,
ostree_repo_finder_resolve_all_async(). This is because the individual
OstreeRepoFinder implementations don't currently access the timestamps
(but I think this could be changed in the future if there's a need).

This commit will allow P2P support to be added to
flatpak_installation_list_installed_refs_for_update, which will allow
GNOME Software to update apps from USB drives while offline (it's
already possible online).

Closes: #1518
Approved by: cgwalters
src/libostree/ostree-repo-finder-avahi.c
src/libostree/ostree-repo-finder-config.c
src/libostree/ostree-repo-finder-mount.c
src/libostree/ostree-repo-finder-override.c
src/libostree/ostree-repo-finder.c
src/libostree/ostree-repo-finder.h
src/libostree/ostree-repo-pull.c
tests/test-repo-finder-config.c